package com.xw.echo.core.client;
import com.xw.echo.core.RpcContext;
import com.xw.echo.core.proxy.JDKProxy;
import com.xw.echo.core.register.HostAndPort;
import com.xw.echo.core.trans.EchoTransPort;
import com.xw.echo.core.trans.TransPort;



public class EchoClient extends EchoClientAbstract {
    private static final ThreadLocal<RpcContext> rpcContextThreadLocal = new ThreadLocal<>();

    //目标的IP+端口
    private HostAndPort hostAndPort;
    //连接池管理器

   //单机客户端初始化
    public EchoClient(HostAndPort hostAndPort) {
        this.hostAndPort = hostAndPort;
    }

    @Override
    public Object creatProxy(Class<?> clazz) {
        managerConnectPool.initConnectionPool(this.hostAndPort);
        TransPort transPort = new EchoTransPort(managerConnectPool.getConnectPool(this.hostAndPort));
        return new JDKProxy(clazz, transPort).createProxy();
    }


}
